/* ----------------------------------------------------------------------------
* File: module_controller_impl.h
*
* Desc: Module controller implementation for Skype plugin
*
* Created: 13/07/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _MODULE_CONTROLLER_IMPL_H_
#define _MODULE_CONTROLLER_IMPL_H_

#include <map>
#include <vector>
#include "module_controller.h"


namespace ModuleManagement
{
	class ModuleControllerImpl : public ModuleController
	{
		typedef std::pair<std::tr1::shared_ptr<BaseModule>, std::string>	ModuleChatPair;
		typedef std::map<unsigned int, std::tr1::shared_ptr<BaseModule>>	ModuleMap;
		typedef std::map<unsigned int, ModuleChatPair>						ModuleChatMap;
	public:
		ModuleControllerImpl()
		{
		}
		~ModuleControllerImpl()
		{
		}

		virtual Common::Error RegisterModule(const BaseModule* module, size_t& ID);
		virtual Common::Error RegisterModule(const BaseModule* module, const std::string& ChatName, size_t& ID);
		virtual Common::Error UnregisterModule(size_t ID);
		virtual const BaseModule* FindModuleByID(size_t ID);
		virtual std::vector<BaseModule*> FindModulesByChat(const std::string& ChatName, const ModuleType& type = MODULE_TYPE_UNKNOWN);

	private:
		std::vector<BaseModule*> GetAllModulesByChat(const std::string& ChatName);
		std::vector<BaseModule*> GetSpecificModuleByChat(const std::string& ChatName, const ModuleType& type);

		ModuleMap m_Modules;
		ModuleChatMap m_ChatModules;
	};
}

#endif // _MODULE_CONTROLLER_IMPL_H_